package blockchain

import (
	"context"

	"github.com/shopspring/decimal"
	"github.com/zeromicro/go-zero/core/logx"
	"private-domain-overseas-service/app/business/api/internal/svc"
	"private-domain-overseas-service/app/business/api/internal/types"
)

type BlockchainWalletFeeLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 区块链钱包手续费
func NewBlockchainWalletFeeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BlockchainWalletFeeLogic {
	return &BlockchainWalletFeeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *BlockchainWalletFeeLogic) BlockchainWalletFee(req *types.BalanceBlockchainWalletFeeRequest) (resp *types.BlockchainWalletFeeResponse, err error) {
	// 百分之一
	baiDecimal := decimal.NewFromInt32(100)
	// 手续费（千分之一）
	//gasPriceRate := decimal.NewFromFloat(constant.GasPriceRate)
	// 计算预估手续费
	//estimatedGasFeeHzb := decimal.NewFromInt(req.Amounts).Mul(gasPriceRate)
	estimatedGasFeeHzb := decimal.NewFromInt(0)
	// 计算预计到账
	estimatedHzb := decimal.NewFromInt(req.Amounts).Sub(estimatedGasFeeHzb)

	// 组装返回数据
	resp = &types.BlockchainWalletFeeResponse{
		IntegralBalance:    "0",
		EstimatedHzb:       estimatedHzb.Div(baiDecimal).StringFixed(2),
		EstimatedGasFeeHzb: estimatedGasFeeHzb.Div(baiDecimal).StringFixed(2),
	}
	return
}
